<template>
	<view>
		<view style="height: 123.81rpx;width: 750rpx;padding: 41rpx 70rpx;display: flex;justify-content: space-between;box-sizing: border-box;background: #F2F2F2;align-items: center;">
			<view v-for="(itme,index) in arr_bu" :key="index" style="display: flex;height: 25.55rpx;align-items: center;">
				<view style="font-size: 25.55rpx;height: 41.31rpx;width: 41.31rpx;line-height: 41.31rpx;text-align: center;margin-right: 17rpx;border-radius:50% ;" :class="num <index?'bian': 'bian_' ">{{itme.shuju}}</view>
				<view style="font-size: 25.55rpx;">{{itme.zifu}}</view>
				<image :src="itme.img" style="width: 15.71rpx;height: 16.9rpx; vertical-align: middle;margin-left:22.744rpx ;"></image>
			</view>
		</view>
		<view style="width: 700.64rpx;height: 438.5rpx;background: #FFFFFF;border-radius: 18.12rpx;margin-left: 24.77rpx;box-sizing: border-box;padding: 25.616rpx 31.04rpx 36.24rpx 31.04rpx;">
			<view>
				<text style="font-size: 26.58rpx;color: #383838;">机构营业执照</text>
				<text style="font-size: 21.744rpx;color: #BBBBBB;">（{{text}}）</text>
			</view>
			<view @tap="toimg">
				<view style="border: #BBBBBB 1rpx dashed;width: 637.824rpx;height: 307.8rpx;margin-top: 25rpx;position: relative;text-align: center;overflow: hidden;" v-if="!img">
					<view style="width: 58.58rpx;height: 58.58rpx;border-radius: 50%;background: #FF7300;position: absolute;top: 113.5rpx;left: 289rpx;display: flex;justify-content: center;align-items: center;">
						<view style="height:40rpx ;width: 4rpx;background: #FFFFFF;display: flex;flex-direction:column;justify-content: center;position: relative;">
							<view style="height:4rpx ;width: 40rpx;background: #FFFFFF;position: absolute;left: -20rpx;"></view>
						</view>
					</view>
					<view style="font-size: 24.15rpx;color: #494949;margin-top:214.4rpx ;">上传营业执照</view>
				</view>
				<view v-if="img">
					<image :src="img" mode="" style="width: 637.824rpx;height: 307.8rpx;margin-top: 25rpx;"></image>
				</view>
			</view>
		</view>
		<view style="width: 700.64rpx;height: 289.32rpx;background: #FFFFFF;border-radius: 18.12rpx;margin-left: 24.77rpx;box-sizing: border-box;padding: 25.616rpx 24.15rpx 36.24rpx 24.15rpx;margin-top: 19rpx;">
			<view>
				<text style="font-size: 26.58rpx;color: #383838;">机构图片</text>
				<text style="font-size: 21.744rpx;color: #BBBBBB;">（{{text_}}）</text>
			</view>
			<view style="display: flex;margin-top: 39rpx;">
				<view v-for="(itme,index) in img_list" :key="index" v-if="img_list.length>0" style="margin-right: 18rpx;">
					<image :src="itme" mode="" style="width: 150.4rpx;height: 150.4rpx;border-radius: 12rpx;" ></image>
				</view>
				<view @tap="add" v-if="img_list.length<4">
					<image :src="tupian" style="width: 150.4rpx;height: 150.4rpx;"></image>
				</view>
			</view>
		</view>
		<view style="font-size: 21.74rpx;color: #BBBBBB;margin-top: 33.21rpx;padding-left:55rpx ;letter-spacing: 2rpx;">
			<view style="margin-bottom: 9rpx;">信息安全声明</view>
			<view>所填信息仅用于门店入驻审核，请放心填写</view>
		</view>
		<view style="width: 648.7rpx;height: 85.76rpx;background: #FF7300;color: #FFFFFF;text-align: center;line-height:  85.76rpx;font-size: 29rpx;margin:38rpx 0 41.1rpx 50.73rpx;border-radius: 42.9rpx;" @tap="go">
			提交审核
		</view>
	</view>
</template>
<script>
	import qiniu from "../../../common/qiniuUploader.js"
	export default {
		data() {
			return {
				img_list:[],
				text:"营业执照必传, " + " " + " 确保文字图片清晰",
				num:-1,
 				arr_bu:[
					{
						shuju:"01",
						zifu:"添加门店",
						img:"../../../static/newshouye/jiaotou_.png"
					},
					{
						shuju:"02",
						zifu:"完善资料",
						img:"../../../static/newshouye/jiaotou_.png"
					},
					{
						shuju:"03",
						zifu:"资质认证",
						img:""
					}
				],
				img:"",
				text_:"必传：前台照一张和环境照两张 ",
				jiao:{},
				user_id:"",
				tupian: "http://img.curiousmore.com/368515"
			}
		},
		methods:{
		async	go(){
			if(this.img != "" && this.img_list.length >= 3){
				const res = await this.$myRequest({
					url:"/mastermechanism/insert",
					methed:"POST",
					data:{
						contact_telephone:this.jiao.fuze_dianhua,
						contacts:this.jiao.fuze_name,
						contacts_title:"校长",
						introduction_content:this.jiao.neirong,
						introduction_pic:this.img_list.toString(),
						latitude: +this.jiao.weidu,
						longitude:+this.jiao.jingdu,
						categories_child: this.jiao.categories_child,
						mechanism_addr:this.jiao.jigou_adderr,
						mechanism_logo:this.jiao.img_logo,
						mechanism_name:this.jiao.jigou_name,
						mechanism_telephone:this.jiao.lianxi_dianhua,
						support_means:this.img,
						user_id:this.user_id.toString(),
						type:"teach_paypal",
						categories:this.jiao.leixing,
						categories_child:this.jiao.jingying_,
						payee_logon_id:this.jiao.zhifubao,
						is_support_teach_paypal	:this.jiao.jiaofu_xuan.toString(),
						facade_view:this.jiao.img_mian
					},
					header:{
						'content-type':'application/json' 
					}
				})
				if(res.code == 0){
					uni.showToast({
						title: "提交成功"
					})
					uni.navigateTo({
						url:"/pages/tabBer/newsshouye/newsshouye"
					})
					try{
						uni.setStorageSync("Settle",true)
					}catch(e){}
				}
			}else{
				uni.showToast({
					title:"信息不完整",
					icon:"none"
				})
			}
				
			},
			add(){
				let me = this
					uni.showActionSheet({
					  itemList: ['从手机相册选择', '拍照'],
					  success: function(res) {
						let aa = []
						if(res.tapIndex == 1){
							aa = ["camera"]
						}else{
							aa = ["album"]
						}
						me.to()
						uni.chooseImage({
							count: 1,
							sizeType: ['compressed'],
							sourceType: aa,
							success:(res_) => {
								let filePath = res_.tempFilePaths[0]
								if(me.token != ""){
									qiniu.upload(filePath, (res) => {
										me.img_list.push(res.fileUrl)
									}, (error) => {
										console.log('error: ' + error);
									}, {
										region: 'ECN',
										domain: 'http://img.curiousmore.com', 
										key: me.key, 
										uptoken: me.token, 
									}, (res) => {
										console.log('上传进度', res.progress)
										console.log('已经上传的数据长度', res.totalBytesSent)
										console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
									}, () => {
										// 取消上传
									}, () => {
										// `before` 上传前执行的操作
									}, (err) => {
										// `complete` 上传接受后执行的操作(无论成功还是失败都执行)
									});
								}
							}
						})
					  },
					fail: function(res) {
						console.log(res.errMsg,"2222222222")
					  }
					})
			},
			to(){
				this.key = Math.ceil(Math.random()*1000000)
				uni.request({
					url:"https://curiousmore.com/qmore/push/upload/getToken",
					data:{
						key:this.key
					},
					method:"post",
					success:(res) => {
						this.token = res.data.data
					}
				})
			},
			toimg(){
				let me = this
				uni.showActionSheet({
				  itemList: ['从手机相册选择', '拍照'],
				  success: function(res) {
					let aa = []
					if(res.tapIndex == 1){
						aa = ["camera"]
					}else{
						aa = ["album"]
					}
					me.to()
					uni.chooseImage({
						count: 1,
						sizeType: ['compressed'],
						sourceType: aa,
						success:(res_) => {
							let filePath = res_.tempFilePaths[0]
							if(me.token != ""){
								qiniu.upload(filePath, (res) => {
									me.img = res.fileUrl
								}, (error) => {
									console.log('error: ' + error);
								}, {
									region: 'ECN',
									domain: 'http://img.curiousmore.com', 
									key: me.key, 
									uptoken: me.token, 
								}, (res) => {
									console.log('上传进度', res.progress)
									console.log('已经上传的数据长度', res.totalBytesSent)
									console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
								}, () => {
									// 取消上传
								}, () => {
									// `before` 上传前执行的操作
								}, (err) => {
									// `complete` 上传接受后执行的操作(无论成功还是失败都执行)
								});
							}
						}
					})
				  },
				fail: function(res) {
					console.log(res.errMsg)
				  }
				})
			},
		},
		onLoad(option) {
			const val = JSON.parse(decodeURIComponent(option.num));
			this.jiao = val
			try{
				this.user_id = uni.getStorageSync('userif_list').user_id
			}catch(e){}
		},
		onShow() {
			
		}
	}
</script>
<style lang="scss" scoped>
	.bian{
		background: #FF7300;
		color: #FFFFFF;
	}
	.bian_{
		background: #E8E8E8;
		color: #C1C1C1;
	}
</style>